alter table sales_dtl add scaleproduct varchar(50) go alter PROCEDURE UpdateSalesDetail @CentralProductCode as Varchar(50), @Quantity as float, @UserId as Varchar(20), @ShopLocation as Varchar(50), @OrderID as int, @SupplierCode as Varchar(50), @ProductDescription as Varchar(200), @UnitOfSale as Varchar(20), @UnitPrice as money, @DiscountType as Char(1), @DiscountValue as float, @ReasonForDiscount as Varchar(100), @TotalPrice as Money, @PromotionDiscountDescription as Varchar(50), @PromotionDiscountValue as money, @DeliveryQty as decimal, @ProductVat as money, @NonStockable as char(1), @AdjustQty as float, @LineWeight as float, @VatPercentage as float, @OverallDiscPercentage as float, @CostPrice as Money, @EmployeeLinkedToSales as varchar(20), @BrCode as varchar(10), @ScaleProduct as varchar(50) as Update Product_Master set Physical_Qty=isNull(Physical_Qty,0)-@Quantity where Central_Product_Code=@CentralProductCode -----This Updates the Shop Location Stock Qty...... if exists(select * from Product_StockList where CentralProductCode=@CentralProductCode and Location_Code=@ShopLocation) begin Update Product_StockList set Quantity=isNull(Quantity,0)-@Quantity where CentralProductCode=@CentralProductCode and Location_Code=@ShopLocation end else begin insert into Product_StockList (CentralProductCode,Quantity,ModifiedBy,ModifiedDateTime,Location_Code,Br_Code) values (@CentralProductCode,-@Quantity,@UserId,getdate(),@ShopLocation,@BrCode) end -----This saves the sales details record for a particular product in Stock Transactions Table insert into Stock_Transactions(CentralProductCode,TransactionType,TransactionBy,Quantity,SalesRef,PickedLocation) values(@CentralProductCode,'Sales',@UserID,@Quantity,convert(varchar(50),@OrderID),@ShopLocation ) /**/ declare @SalesPrice as float set @SalesPrice=0 declare @WeighProduct as bit set @WeighProduct=0 select @SalesPrice=price,@WeighProduct=(select isNull(WeighProduct,0) from product_master where central_product_code=@CentralProductCode) from product_qty_pricelist where is_deleted='N' and Number_Of_Items=1 and Centralproductcode=@CentralProductCode if @CentralProductCode<>'9999' and @CentralProductCode<>'0000' and @CentralProductCode<>'1111' and upper(@CentralProductCode)<>upper('fruitnveg') and @WeighProduct<>1 and @SupplierCode<>'WeightProduct' and @CentralProductCode<>'22222222' and @CentralProductCode<>'33333333' begin if @SalesPrice<>@UnitPrice begin declare @promodiscountvalue float set @promodiscountvalue=0 set @promodiscountvalue=@promodiscountvalue+(@Quantity * (@SalesPrice- @UnitPrice)) --print convert(varchar(20),@PromotionDiscountValue) set @PromotionDiscountValue=@PromotionDiscountValue + @promodiscountvalue set @PromotionDiscountDescription=@PromotionDiscountDescription + convert (Varchar(10),@promodiscountvalue) + ' @Family Grouping' set @UnitPrice=@SalesPrice end -- Update sales_mst set OverallPromotionsDiscAmt=isNull(OverallPromotionsDiscAmt,0) + @promodiscountvalue where sales_orderid=@OrderID Update sales_mst set OverallPromotionsDiscAmt=isNull(OverallPromotionsDiscAmt,0) + isNull(@promodiscountvalue,0) where sales_orderid=@OrderID end insert into Sales_Dtl (Sales_OrderID,CentralProductCode,SupplierCode,ProductDescription,Qty,UnitPrice,UnitOfSale,DiscountType,DiscountValue, ReasonForDiscount,PromotionalDiscountType,PromotionalDiscountValue,DeliveryQty,DeliveryDateTime,NonStockable,VatAmt,TotalLinePrice,ProductWeight, VatPercentage,OverallDiscPercentage,CostPrice,EmployeeLinkedToSales,Br_Code,ScaleProduct) Values (@OrderID,@CentralProductCode,@SupplierCode,@ProductDescription,@Quantity,@UnitPrice,@UnitOfSale,@DiscountType,@DiscountValue, @ReasonForDiscount ,@PromotionDiscountDescription ,@PromotionDiscountValue,@DeliveryQty ,getdate(),@NonStockable ,@ProductVat,@TotalPrice, @LineWeight,@VatPercentage,@OverallDiscPercentage,@CostPrice,@EmployeeLinkedToSales,@BrCode,@ScaleProduct) GO